import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:new_yuqib_app/yqbConfig/color_theme.dart';
import 'package:new_yuqib_app/yqbConfig/file_path.dart';
import 'package:new_yuqib_app/yqbConfig/yqb_base.dart';
import 'package:new_yuqib_app/yqbView/HomeView/controller.dart';
import 'package:new_yuqib_app/yqbWidget/video_play_widget.dart';
import 'package:video_player/video_player.dart';

import 'al_widget.dart';

///首页
class HomeView extends StatelessWidget {
  const HomeView({super.key});

  @override
  Widget build(BuildContext context) {
    final logic = Get.put(HomeViewController());
    return Scaffold(
      appBar: AppBar(
        toolbarHeight: 100,
        flexibleSpace: FlexibleSpaceBar(
          background: Image.asset(FilePath.barBgPath,
              width: double.maxFinite, fit: BoxFit.cover),
          titlePadding: const EdgeInsets.only(left: 12, bottom: 36),
          title: Row(
            children: [
              Container(
                width: 40,
                height: 40,
                margin: const EdgeInsets.only(right: 8),
                decoration: BoxDecoration(
                  image: const DecorationImage(
                      image: AssetImage(FilePath.iconPath), fit: BoxFit.fill),
                  borderRadius: BorderRadius.circular(8),
                ),
              ),
              const Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                mainAxisSize: MainAxisSize.min,
                children: [
                  Text(
                    appName,
                    style: TextStyle(
                        fontSize: 20,
                        color: ColorTheme.primaryTextColor,
                        fontWeight: FontWeight.w500),
                  ),
                  Text(
                    "专业解决信用卡、网贷、银行信贷逾期",
                    style: TextStyle(
                        color: ColorTheme.primaryTextColor2, fontSize: 14),
                  ),
                ],
              ),
            ],
          ),
        ),
      ),
      body: SingleChildScrollView(
        child: Column(
          children: [
            const VideoPlayWidget(videoUrl: testVideoUrl),
            const SizedBox(height: 24),
            Image.asset(FilePath.bannerPath, width: double.maxFinite),
            const SizedBox(height: 34),
            Row(
              children: [
                Image.asset(FilePath.tagPath, height: 16),
                const SizedBox(width: 8),
                const Text(
                  "案例展示",
                  style: TextStyle(
                      color: ColorTheme.primaryTextColor,
                      fontSize: 18,
                      fontWeight: FontWeight.w500),
                ),
              ],
            ),
            const SizedBox(height: 16),
            SizedBox(
              height: 150,
              child: ListView.separated(
                scrollDirection: Axis.horizontal,
                padding: const EdgeInsets.symmetric(horizontal: 16),
                itemBuilder: (context, index) {
                  return Container(
                    width: 240,
                    margin: const EdgeInsets.only(bottom: 16),
                    decoration: BoxDecoration(
                      color: Colors.blue,
                      borderRadius: BorderRadius.circular(8),
                    ),
                    child: const AlWidget(),
                  );
                },
                itemCount: 4,
                separatorBuilder: (BuildContext context, int index) {
                  return const SizedBox(width: 12);
                },
              ),
            ),
            const SizedBox(height: 24),
            Row(
              children: [
                Image.asset(FilePath.tagPath, height: 16),
                const SizedBox(width: 8),
                const Text(
                  "法律服务",
                  style: TextStyle(
                      color: ColorTheme.primaryTextColor,
                      fontSize: 18,
                      fontWeight: FontWeight.w500),
                ),
              ],
            ),
            Column(
              children: [

              ],
            ),
          ],
        ),
      ),
    );
  }
}
